

using System;
using System.Collections.Generic;
using System.Text;
using EntityLayer;
using System.Data;
using DataAccessLayer;
using InfraStructureLayer;

namespace DataLayer
{
	public class datCategories
	{
		public datCategories()
		{
		}
		
		#region  Code Factory Generated Methods
		public void DeleteCategoriesByCategoryId(entCategories parEntCategories, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
			insDbParamCollection.Add("@pCategoryId",parEntCategories.CategoryId);
			parDbConnector.ExecuteNonQuery("DeleteCategoriesByCategoryId",insDbParamCollection);
		}
		public void InsertCategories(entCategories parEntCategories, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
			insDbParamCollection.Add("@pCategoryDescription",parEntCategories.CategoryDescription);
			insDbParamCollection.AddOutput("@pCategoryId",DbType.Int32);
			parDbConnector.ExecuteNonQuery("InsertCategories",insDbParamCollection);
			parEntCategories.CategoryId = Convert.ToInt32(insDbParamCollection.GetOutPutParameter().Value);
		}
		public void UpdateCategoriesByCategoryId(entCategories parEntCategories, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
			insDbParamCollection.Add("@pCategoryId",parEntCategories.CategoryId);
			
			insDbParamCollection.Add("@pCategoryDescription",parEntCategories.CategoryDescription);
			parDbConnector.ExecuteNonQuery("UpdateCategoriesByCategoryId",insDbParamCollection);
		}
		public DataTable SelectCategories(DbConnector parDbConnector)
		{
			
			return parDbConnector.ExecuteDataTable("SelectCategories",null);
		}
		public void SelectCategoriesByCategoryId(entCategories parEntCategories, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
			insDbParamCollection.Add("@pCategoryId",parEntCategories.CategoryId);
			DataTable insDataTable = new DataTable();
			insDataTable = parDbConnector.ExecuteDataTable("SelectCategoriesByCategoryId",insDbParamCollection);
			if (insDataTable.Rows.Count>0)
			{
				if (insDataTable.Rows[0]["CategoryId"]!=DBNull.Value)
				{
					parEntCategories.CategoryId = Convert.ToInt32(insDataTable.Rows[0]["CategoryId"]);
				}
				if (insDataTable.Rows[0]["CategoryDescription"]!=DBNull.Value)
				{
					parEntCategories.CategoryDescription = insDataTable.Rows[0]["CategoryDescription"].ToString();
				}
			}
		}
		#endregion

        public DataTable SelectCategoriesByLanguageId(DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pLanguageId", CurrentContext.LanguageId);
            return parDbConnector.ExecuteDataTable("SelectCategoriesByLanguageId", insDbParamCollection);
        }
	}
}